<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
	<input type="checkbox">
	<input type="checkbox">
	<input type="checkbox">
	<input type="checkbox">
	<input type="checkbox">
	<br>
	<button>全选</button>
	<button>不选</button>
	<button>反选</button>
	
	<script>
		var  inputs = [...document.querySelectorAll("input")],
			 btns = [...document.querySelectorAll("button")];
			 // 全选  
			btns[0].onclick = function (){
				inputs.forEach(function(item){
					item.checked = true
				})
			}
			
			btns[1].onclick = function (){
				inputs.forEach(function(item){
					item.checked = false
				})
			}
			
			btns[2].onclick = function (){
				inputs.forEach(function(item){
					item.checked = !item.checked
				})
			}
	
	
	</script>
</body>

</html>